package net.lainiao.mycost.service.impl;

import net.lainiao.mycost.bean.RoleMenuInfo;
import net.lainiao.mycost.dao.IAnthorityDAO;
import net.lainiao.mycost.service.IAnthorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/3/22.
 */
@Service
@Transactional
public class AnthorityServiceImpl implements IAnthorityService {
    @Autowired
    private IAnthorityDAO anthorityDAO;

    @Override
    public void add(Integer roleId, Integer[] menuIds) {
        anthorityDAO.delete(roleId);
        for(Integer menuId:menuIds){
            RoleMenuInfo info=new RoleMenuInfo();
            info.setRoleId(roleId);
            info.setMenuId(menuId);
            anthorityDAO.add(info);
        }
    }

    @Override
    public List<RoleMenuInfo> list(RoleMenuInfo info) {
        return anthorityDAO.list(info);
    }

    @Override
    public List<Map> getMenuList(Integer roleId) {
        return anthorityDAO.getMenuList(roleId);
    }
}
